package test.y2020;

import cn.hutool.core.lang.Console;
import common.dto.MultiAppletScenesHisPo;

import java.util.concurrent.*;

/**
 * Created By  醉美柳舞之众星捧月
 *
 * @author song
 * @date 2020/4/24 14:56
 */
public class April7 {
    private static final Executor EXECUTOR = new ThreadPoolExecutor(2, 5, 100, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(10), (ThreadFactory) Thread::new);

    public static void main(String[] args) {
        ArrayBlockingQueue<MultiAppletScenesHisPo> multiAppletSwitchPo = new ArrayBlockingQueue<>(200);
        for (int i = 0; i < 100; i++) {
            try {
                Console.error("~~~~~~~   " + multiAppletSwitchPo.size());
                multiAppletSwitchPo.add(new MultiAppletScenesHisPo());
            } catch (Exception exception) {
                System.out.println("队列满了，，，");
            }
          /*  Console.error("----->>>>>前   " + multiAppletSwitchPo.size());
            EXECUTOR.execute(multiAppletSwitchPo::poll);
            EXECUTOR.execute(multiAppletSwitchPo::poll);
            EXECUTOR.execute(multiAppletSwitchPo::poll);
            EXECUTOR.execute(multiAppletSwitchPo::poll);
            EXECUTOR.execute(multiAppletSwitchPo::poll);
            EXECUTOR.execute(multiAppletSwitchPo::poll);
            Console.error("后<<<<<----- " + multiAppletSwitchPo.size());*/
        }
        Console.error("后<<<<<----- " + multiAppletSwitchPo.size());
    }
}
